$(()=>{
  let goods = $('.main-cart tbody tr')
  function countPrice(){
    let totalPrice = 0
    $.each(goods, function (_, ele) { 
      let num = ele.querySelector('input').value
      let price = ele.querySelector('.ptice').innerText
      price = Number.parseFloat(price.replace(/[^0-9.-]+/g,""))
      let count = num*price
      ele.querySelector('.count').innerText = `$ ${count}`
      totalPrice += count
    });
    $('.total-price').text(`$ ${totalPrice}`)
  }

  // 点击更新
  $('.update-cart').click(function(e){
    countPrice()
  });
})